package org.example.gradle.jp.service;

import gradle.common.core.utils.JsonUtil;
import gradle.mybatis.common.response.ApiResponse;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.example.gradle.jp.BaseTest;
import org.example.gradle.jp.model.dto.StarWordAddDto;
import org.example.gradle.jp.model.dto.StarWordQueryDto;
import org.example.gradle.jp.model.entity.StarWord;
import org.example.gradle.jp.model.entity.StarWordManyEntity;
import org.example.gradle.jp.model.vo.StarWordVo;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * StarWordImpl Test
 *
 * @author 1141193930@qq.com
 */
@Slf4j
public class StarWordImpl extends BaseTest {

    @Resource
    private StarWordService starWordService;

    @Test
    public void insertTest() {

        StarWordAddDto starWordDto = new StarWordAddDto();
        starWordDto.setStarCourseId(1L);
        starWordDto.setWordSampleId(1L);
        starWordDto.setWordOriginal("1");
        starWordDto.setWordChinese("1");
        starWordDto.setWordType("1");


        starWordService.insert(starWordDto);
    }

    @Test
    public void insertTest2() {

        StarWordAddDto starWordDto = new StarWordAddDto();
        starWordDto.setStarCourseId(1L);
        starWordDto.setWordSampleId(1L);
        starWordDto.setWordOriginal("1");
        starWordDto.setWordChinese("1");
        starWordDto.setWordType("1");


        starWordService.insert2("a", 1, starWordDto);
    }

    @Test
    public void starWordManyEntityInsertTest() {

        StarWordManyEntity starWordManyEntity = new StarWordManyEntity();


        StarWord starWordDto = new StarWord();
        starWordDto.setStarCourseId(1L);
        starWordDto.setWordSampleId(1L);
        starWordDto.setWordOriginal("1");
        starWordDto.setWordChinese("1");
        starWordDto.setWordType("1");

        StarWord starWordDto3 = new StarWord();
        starWordDto3.setStarCourseId(1L);
        starWordDto3.setWordSampleId(1L);
        starWordDto3.setWordOriginal("1");
        starWordDto3.setWordChinese("1");
        starWordDto3.setWordType("1");

        StarWord starWordDto2 = new StarWord();
        starWordDto2.setStarCourseId(1L);
        starWordDto2.setWordSampleId(1L);
        starWordDto2.setWordOriginal("1");
        starWordDto2.setWordChinese("1");
        starWordDto2.setWordType("1");

        List<StarWord> starWordDtos = new ArrayList<>();
        starWordDtos.add(starWordDto3);
        starWordDtos.add(starWordDto2);

        starWordManyEntity.setStarWord(starWordDto);
        starWordManyEntity.setStarWordList(starWordDtos);
        starWordService.starWordManyEntityInsertTest(starWordManyEntity);
    }


    @Test
    public void batchInsertTest() {

        StarWordAddDto starWordDto = new StarWordAddDto();
        starWordDto.setStarCourseId(1L);
        starWordDto.setWordSampleId(1L);
        starWordDto.setWordOriginal("1");
        starWordDto.setWordChinese("1");
        starWordDto.setWordType("1");

        StarWordAddDto starWordDto2 = new StarWordAddDto();
        starWordDto2.setStarCourseId(1L);
        starWordDto2.setWordSampleId(1L);
        starWordDto2.setWordOriginal("1");
        starWordDto2.setWordChinese("1");
        starWordDto2.setWordType("1");

        List<StarWordAddDto> starWordDtos = new ArrayList<>();
        starWordDtos.add(starWordDto);
        starWordDtos.add(starWordDto2);

        starWordService.batchInsert(starWordDtos);
    }


    @Test
    public void batchInsertTest2() {

        StarWordAddDto starWordDto = new StarWordAddDto();
        starWordDto.setStarCourseId(1L);
        starWordDto.setWordSampleId(1L);
        starWordDto.setWordOriginal("1");
        starWordDto.setWordChinese("1");
        starWordDto.setWordType("1");

        StarWordAddDto starWordDto2 = new StarWordAddDto();
        starWordDto2.setStarCourseId(1L);
        starWordDto2.setWordSampleId(1L);
        starWordDto2.setWordOriginal("1");
        starWordDto2.setWordChinese("1");
        starWordDto2.setWordType("1");

        List<StarWordAddDto> starWordDtos = new ArrayList<>();
        starWordDtos.add(starWordDto);
        starWordDtos.add(starWordDto2);

        starWordService.batchInsert2(starWordDtos);
    }


    @Test
    public void pageTest() {
        StarWordQueryDto starWordQueryDto = new StarWordQueryDto();
        ApiResponse<List<StarWordVo>> listApiResponse = starWordService.listPage(starWordQueryDto);
        log.info(JsonUtil.toJsonString(listApiResponse));


    }
}
